package td0.Figures;


public final class RevolutionCone extends Shape3D{
	private double height=0;
	private double radius;
	private Point center;
	
	public RevolutionCone(String name, double height, double radius, Point center) {
		super(name);
		this.height = height;
		this.radius = radius;
		this.center = center;
	}	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((center == null) ? 0 : center.hashCode());
		long temp;
		temp = Double.doubleToLongBits(height);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(radius);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RevolutionCone other = (RevolutionCone) obj;
		if (center == null) {
			if (other.center != null)
				return false;
		} else if (!center.equals(other.center))
			return false;
		if (Double.doubleToLongBits(height) != Double
				.doubleToLongBits(other.height))
			return false;
		if (Double.doubleToLongBits(radius) != Double
				.doubleToLongBits(other.radius))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "RevolutionCone " + this.getName() + " [height=" + height + ", radius=" + radius
				+ ", center=" + center + "] volume : " + volume() + " surface : " + surface();
	}

	@Override
	public double volume() {
		return (Math.PI*getRadius()*getRadius()*getHeight())/3;
	}

	@Override
	public void translate(int dx, int dy) {
		getCenter().setX(dx);
		getCenter().setY(dy);
	}

	@Override
	public double surface() {
		return Math.PI*getRadius()*(getRadius() + this.apothem());
	}
	
	public double apothem(){
		return Math.sqrt((getRadius() * getRadius()) + (getHeight() * getHeight()));		
	}

	public void setHeight(double height) {
		this.height = height;
	}

	public double getHeight() {
		return height;
	}

	public void setRadius(double radius) {
		this.radius = radius;
	}

	public double getRadius() {
		return radius;
	}

	public void setCenter(Point point) {
		this.center = point;
	}

	public Point getCenter() {
		return center;
	}

}
